#include<bits/stdc++.h>
using namespace std;
long long n,a[200005],b[200005],s[200005],ma=-2e9;
int main(){
	freopen("color.in","r",stdin); 
	freopen("color.out","w",stdout); 
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=b[i-1])s[i]++;
		s[i]+=s[i-1];
	}
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)ma=max(ma,j-i-(s[j]-s[i-1]));
	}
	cout<<ma;
	
	return 0;
} 
